package edgeEnv

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commEnv"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/OS"
)

type edgeEnv struct {
	cpuId    string
	arch     string
	envType  string
	workMode string
}

func (e *edgeEnv) initialize() {
	// envType
	arg, ok := commEnv.GetArg("envType")
	if ok {
		e.envType = arg.(string)
	}
	if e.envType == "" {
		e.envType = "device"
	}

	// workMode
	arg, ok = commEnv.GetArg("workMode")
	if ok {
		e.workMode = arg.(string)
	}
	if e.workMode == "" {
		e.workMode = "local"
	}

	// workMode
	arg, ok = commEnv.GetArg("workMode")
	if ok {
		e.workMode = arg.(string)
	}
	if e.workMode == "" {
		e.workMode = "local"
	}

	// cpuId
	if OS.Hardware.SerialNumber != "" {
		e.cpuId = OS.Hardware.SerialNumber
	}
	if e.cpuId == "" {
		arg, ok = commEnv.GetArg("envCpuId")
		if ok {
			e.cpuId = arg.(string)
		}
	}

	// arch
	e.arch = OS.Hardware.ARCH
}
